import java.util.Arrays;
import java.util.Scanner;

public class Test {

    /*
    * 双指针解决移动零
    * */

    public static void main(String[] args) {
        int[] nums = {0,1,0,3,12};
        moveZeroes(nums);
        System.out.println(Arrays.toString(nums));
    }

    public static void moveZeroes(int[] nums){
        int cur = 0;
        int dest = -1;
        while(cur < nums.length){
            if(nums[cur] != 0){
                dest++;
                int tmp = nums[dest];
                nums[dest] = nums[cur];
                nums[cur] = tmp;
            }
            cur++;
        }
    }


}
